<template>
  <div class="app-container">
    <!-- <strong>讲师列表</strong> -->
    <!--查询表单-->
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input v-model="adminSuperQuery.name" placeholder="教师姓名"/>
      </el-form-item>

      <el-button type="primary" icon="el-icon-search" @click="getList()">查询</el-button>
      <el-button type="default" @click="resetData()">清空</el-button>
    </el-form>

    <!-- 表格 -->
    <el-table
      :data="list"
      style="width: 100%"
    >
      <el-table-column
        label="序号"
        width="70"
        align="center"
      >
        <template slot-scope="scope">
          {{ (page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column label="教师工号" prop="uid" align="center"/>

      <el-table-column label="教师姓名" prop="name" align="center"/>

      <el-table-column label="周几" prop="week" align="center"/>

      <el-table-column label="第几节" prop="section" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.section === '1'">第1-2 节</span>
          <span v-if="scope.row.section === '3'">第 3-4 节</span>
          <span v-if="scope.row.section === '5'">第 5-6 节</span>
          <span v-if="scope.row.section === '7'">第 7-8 节</span>
          <span v-if="scope.row.section === '9'">第 9-10 节</span>
        </template>
      </el-table-column>

      <el-table-column label="签到状态" prop="status" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.status === '0'">尚未到签到时间</span>
          <span v-if="scope.row.status === '1'">签到成功</span>
          <span v-if="scope.row.status === '2'">迟到</span>
          <span v-if="scope.row.status === '3'">未签</span>
          <span v-if="scope.row.status === '4'">代签</span>
        </template>
      </el-table-column>

    </el-table>

    <!-- 分页 -->
    <el-pagination
      :current-page="page"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getList"
    />


  </div>
</template>

<script>
// import teacher from '@/api/adm/teacherAdmin'
import * as teacher from '@/api/adm/teacherAdmin'
import { disable, disableTeacher } from '@/api/adm/teacherAdmin'

export default {
  data() {
    return {
      list: null, // 查询之后接口返回集合
      page: 1, // 当前页
      limit: 10, // 每页记录数
      total: 0, // 总记录数
      adminSuperQuery: {} // 条件封装对象
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 条件查询教师信息
    getList(page = 1) {
      this.page = page
      teacher.findAllSignPeople(this.page, this.limit, this.adminSuperQuery)
        .then(response => {
          // 请求成功
          // response接口返回的数据
          // console.log(response)
          this.list = response.data.rows
          this.total = response.data.total
          console.log(this.list)
          console.log(this.total)
        })
    },

    //清空要查询的内容
    resetData() {
      this.adminSuperQuery = {}
      this.getList()
    },

    //删除教师账号
    updateSign(id){
      teacher.updateSign(id).then(response => {
        //删除成功
        this.$message({
          message: '代签成功',
          type: 'success'
        });
        this.getList()
      })
    },

    //修改教师信息
    updateDataById(){
    },

    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
    handleDelete(index, row) {
    }
  }
}
</script>
<style>
.demo-table-expand {
  font-size: 0;
}

.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}

.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}

.edit-button {
  color: rgb(217, 149, 38); /* 紫色 */
}


.delete-button {
  color: rgb(65, 150, 215); /* 红色 */
}
</style>
